package com.niit.chat.controller;

import com.niit.chat.service.UserService;
import com.niit.chat.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/nickname/{userId}")
    public String getUserNickname(@PathVariable Long userId) {
        return userService.getNicknameById(userId).orElse("未知用户");
    }

    @GetMapping("/{userId}")
    public User getUserById(@PathVariable Long userId) {
        return userService.getById(userId);
    }
}